a = input("Введите скобочную последовательность")
stack = []
vx = ['(', '[', '{', '<']
zk = [')', ']', ' }', '>']
for m in a:
    if m in vx:
        stack.append(m)
    elif m in zk:
        if not stack or zk[vx.index(stack.pop())] != m:
            print(False)
            break
else:
    print(not stack)
